package com.example.activitysign.controller;

import com.example.activitysign.pages.AjaxResult;
import com.example.activitysign.pages.PageResult;
import com.example.activitysign.pages.PageValidate;
import com.example.activitysign.service.IActivityUserAwardRecordService;
import com.example.activitysign.validate.ActivityUserAwardRecordCreateValidate;
import com.example.activitysign.validate.ActivityUserAwardRecordSearchValidate;
import com.example.activitysign.validate.ActivityUserAwardRecordUpdateValidate;
import com.example.activitysign.vo.activity.ActivityUserAwardRecordDetailVo;
import com.example.activitysign.vo.activity.ActivityUserAwardRecordListedVo;
import lombok.extern.slf4j.Slf4j;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;

/**
 * 用户奖品记录管理
 */
@Slf4j
@RestController
@RequestMapping("api/activityUserAwardRecord")
public class ActivityUserAwardRecordController {

    @Resource
    private IActivityUserAwardRecordService iActivityUserAwardRecordService;

    @GetMapping("/list")
    public AjaxResult<PageResult<ActivityUserAwardRecordListedVo>> list(@Validated PageValidate pageValidate,
                                                                        @Validated ActivityUserAwardRecordSearchValidate searchValidate) {
        PageResult<ActivityUserAwardRecordListedVo> list = iActivityUserAwardRecordService.list(pageValidate, searchValidate);
        return AjaxResult.success(list);
    }

    @GetMapping("/detail")
    public AjaxResult<ActivityUserAwardRecordDetailVo> detail(@Validated @RequestParam("id") Long id) {
        ActivityUserAwardRecordDetailVo detail = iActivityUserAwardRecordService.detail(id);
        return AjaxResult.success(detail);
    }

    /**
     * 用户奖品记录新增
     *
     * @param createValidate
     * @return
     */
    @PostMapping("/add")
    public AjaxResult<Object> add(@Validated @RequestBody ActivityUserAwardRecordCreateValidate createValidate) {
        iActivityUserAwardRecordService.add(createValidate);
        return AjaxResult.success();
    }

    /**
     * 用户奖品记录编辑
     *
     * @param updateValidate
     * @return
     */
    @PostMapping("/edit")
    public AjaxResult<Object> edit(@Validated @RequestBody ActivityUserAwardRecordUpdateValidate updateValidate) {
        iActivityUserAwardRecordService.edit(updateValidate);
        return AjaxResult.success();
    }


}
